<?php

/*
  Plugin Name: User Custom Fields
  Version: 1.5
  Plugin URI: http://www.ricardolanes.com.br
  Description:
  Author: Ricardo Lanes
  Author URI: http://www.ricardolanes.com.br
 */

add_action('admin_head', 'hide_personal_options');
add_action('admin_menu', 'remove_menus');


function hide_personal_options() {

    if (!current_user_can('manage_capabilities')) {

        echo "	<script type='text/javascript'>jQuery(document).ready(function($) {
				jQuery('form#your-profile > h3').remove();
				jQuery('form#your-profile').show();
				jQuery('form#your-profile > h3:first').remove();
				jQuery('form#your-profile > table:first').remove();
				jQuery('form#your-profile label[for=url], form#your-profile input#url').remove();
				jQuery('form#your-profile label[for=description], form#your-profile textarea#description, form#your-profile span.description').remove();
				jQuery('form#createuser label[for=role], form#createuser select#role').remove();
				jQuery('form#createuser label[for=url], form#createuser input#url').remove();
				});
				</script>";
    }
}


function remove_menus() {
    global $menu;
    $restricted = array(__('Posts'));
    end($menu);
    while (prev($menu)) {
        $value = explode(' ', $menu[key($menu)][0]);
        if (in_array($value[0] != NULL ? $value[0] : "", $restricted)) {
            unset($menu[key($menu)]);
        }
    }
}